<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8" />
		<title>4.增强原生方法</title>
	</head>
	<body>
		<script type="text/javascript" >
			let arr = [1,2,3,4,5,6,7]
			let arr2 = [2,4,6,8,10]
			let arr3 = [6,6,6,6,6,6,6]
			let arr4 = [8,8,8,8,8,8,8]

			//需求：对数组原生的push方法进行增强，增强的效果是：push进去的数字比原来大1

			//具体实现
			//第一步：将数组原型对象上的push缓存一份
			const originalPush = Array.prototype.push

			//第二步
			Array.prototype.push = function(value){
				value += 1
				// console.log('push成功被调用了',this,value)
				// this.push(value) //一定不要这么写，会造成死循环
				return originalPush.call(this,value)
			}

			/* *************************************************** */

			let x1 = arr.push(8)
			let x2 = arr2.push(8)
			let x3 = arr3.push(8)
			console.log(x1,x2,x3)
			
		</script>
	</body>
</html>